<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Hexo 搭建个人博客详细教程 | Licardo</title><meta name="author" content="Licardo"><meta name="copyright" content="Licardo"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Hexo 搭建个人博客详细教程 2019-09-30   本文的对象是仅会电脑开机的小伙伴，必须没有一点关于网络和代码的知识。如果你已知道一些知识，可能本文不适合你，因为本文将会是史上最详细的 Hexo 教程。  1. Hexo 介绍本文会详细的介绍如何使用 Hexo 搭建个人博客。Hexo 是基于 Node.js 的快速、简洁且高效的博客框架，拥有超快速度、一键部署、支持 Markdown、丰富">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo 搭建个人博客详细教程">
<meta property="og:url" content="https://blog.licardo.cn/posts/57ddc7cc/index.html">
<meta property="og:site_name" content="Licardo">
<meta property="og:description" content="Hexo 搭建个人博客详细教程 2019-09-30   本文的对象是仅会电脑开机的小伙伴，必须没有一点关于网络和代码的知识。如果你已知道一些知识，可能本文不适合你，因为本文将会是史上最详细的 Hexo 教程。  1. Hexo 介绍本文会详细的介绍如何使用 Hexo 搭建个人博客。Hexo 是基于 Node.js 的快速、简洁且高效的博客框架，拥有超快速度、一键部署、支持 Markdown、丰富">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/blogging_vpvv.svg">
<meta property="article:published_time" content="2019-09-30T00:00:00.000Z">
<meta property="article:modified_time" content="2024-07-26T09:42:54.343Z">
<meta property="article:author" content="Licardo">
<meta property="article:tag" content="Hexo">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/blogging_vpvv.svg"><link rel="shortcut icon" href="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/favicon.ico"><link rel="canonical" href="https://blog.licardo.cn/posts/57ddc7cc/index.html"><link rel="preconnect" href="https://cdn.staticfile.org"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/5.0.33/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?335d5a7787e03ba0532c58a4ef332c24";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.staticfile.org/egjs-infinitegrid/4.11.1/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: true,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Hexo 搭建个人博客详细教程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-07-26 09:42:54'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/avatar.png" onerror="onerror=null;src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">27</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">12</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/books/"><i class="fa-fw fas fa-book"></i><span> 书籍</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-film"></i><span> 电影</span></a></li><li><a class="site-page child" href="/games/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/contact/"><i class="fa-fw fas fa-comments"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/friends/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" target="_blank" rel="noopener" href="https://run.licardo.cn"><i class="fa-fw fas fa-running"></i><span> 跑步</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/blogging_vpvv.svg')"><nav id="nav"><span id="blog-info"><a href="/" title="Licardo"><img class="site-icon" src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/avatar.png"/><span class="site-name">Licardo</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/books/"><i class="fa-fw fas fa-book"></i><span> 书籍</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-film"></i><span> 电影</span></a></li><li><a class="site-page child" href="/games/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/contact/"><i class="fa-fw fas fa-comments"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/friends/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" target="_blank" rel="noopener" href="https://run.licardo.cn"><i class="fa-fw fas fa-running"></i><span> 跑步</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Hexo 搭建个人博客详细教程</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-09-30T00:00:00.000Z" title="发表于 2019-09-30 00:00:00">2019-09-30</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-07-26T09:42:54.343Z" title="更新于 2024-07-26 09:42:54">2024-07-26</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Hexo/">Hexo</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Hexo 搭建个人博客详细教程"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/posts/57ddc7cc/#post-comment"><span id="twikoo-count"><i class="fa-solid fa-spinner fa-spin"></i></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Hexo-搭建个人博客详细教程"><a href="#Hexo-搭建个人博客详细教程" class="headerlink" title="Hexo 搭建个人博客详细教程"></a>Hexo 搭建个人博客详细教程</h1><blockquote>
<p>2019-09-30</p>
</blockquote>
<ul>
<li>本文的对象是仅会电脑开机的小伙伴，必须没有一点关于网络和代码的知识。如果你已知道一些知识，可能本文不适合你，因为本文将会是史上最详细的 Hexo 教程。</li>
</ul>
<h3 id="1-Hexo-介绍"><a href="#1-Hexo-介绍" class="headerlink" title="1. Hexo 介绍"></a>1. Hexo 介绍</h3><p>本文会详细的介绍如何使用 <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a> 搭建个人博客。Hexo 是基于 Node.js 的快速、简洁且高效的博客框架，拥有超快速度、一键部署、支持 Markdown、丰富的插件等优秀的特性。</p>
<p>以上是官方对于 Hexo 的描述，出了以上的描述，利用 Hexo 搭建个人博客还有以下特点：</p>
<ol>
<li><p>全是静态文件，访问速度快</p>
</li>
<li><p>免费方便，不用花一分钱就可以搭建一个自由的个人博客，不需要服务器不需要后台</p>
</li>
<li><p>可以随意绑定自己的域名</p>
</li>
<li><p>数据绝对安全，基于github、coding等的版本管理，想恢复到哪个历史版本都行</p>
</li>
<li><p>博客内容可以轻松打包、转移、发布到其它平台</p>
<p>等等…</p>
</li>
</ol>
<h4 id="1-1-准备工作"><a href="#1-1-准备工作" class="headerlink" title="1.1 准备工作"></a>1.1 准备工作</h4><p>在使用 Hexo 搭建个人博客之前，你得要做一些准备工作，这些工作是必须的，相当于 Hexo 搭建并且运行的基石，你不能跳过</p>
<ol>
<li><p>一个 <a target="_blank" rel="noopener" href="https://github.com/">GitHub</a> 账户（<a target="_blank" rel="noopener" href="https://coding.net/">Coding</a> 或者 <a target="_blank" rel="noopener" href="https://gitee.com/">码云</a> 也可以，但由于 GitHub 是最主流的平台，所以本文以 GitHub 为例，如对其他平台有疑问，欢迎提问)</p>
</li>
<li><p>安装 <a target="_blank" rel="noopener" href="https://nodejs.org/en/">Node.js</a>，Node.js 是多平台的，去官网选择相应的系统版本下载安装即可</p>
</li>
<li><p>安装 <a target="_blank" rel="noopener" href="https://git-scm.com/">Git</a>，Git 也是多平台的，去官网选择相应的系统版本下载安装即可。上文提到的 GitHub、Coding、码云都是基于 Git 的代码托管平台</p>
</li>
</ol>
<h3 id="2-设置-GitHub-博客"><a href="#2-设置-GitHub-博客" class="headerlink" title="2. 设置 GitHub 博客"></a>2. 设置 GitHub 博客</h3><h4 id="2-1-创建-GitHub-仓库"><a href="#2-1-创建-GitHub-仓库" class="headerlink" title="2.1. 创建 GitHub 仓库"></a>2.1. 创建 GitHub 仓库</h4><p>新建一个名为<code>你的用户名.github.io</code>的仓库。比如说，如果你的 GitHub 用户名是<code>L1cardo</code>，那么你就新建<code>l1cardo.github.io</code>的仓库（必须是你的用户名，其它名称无效），将来你的网站访问地址就是 <a target="_blank" rel="noopener" href="http://l1cardo.github.io/">http://l1cardo.github.io</a></p>
<p>有几个需要注意的地方</p>
<ol>
<li>注册的邮箱一定要验证，否则不会成功</li>
<li>仓库名字必须是：<code>username.github.io</code>，其中<code>username</code>是你的用户名</li>
</ol>
<h4 id="2-2-绑定域名（可选）"><a href="#2-2-绑定域名（可选）" class="headerlink" title="2.2. 绑定域名（可选）"></a>2.2. 绑定域名（可选）</h4><p>当然，你不绑定域名肯定也是可以的，就用刚刚创建的的 <code>你的用户名.github.io</code> 来访问。如果你想更个性一点，想拥有一个属于自己的域名，那也是OK的。就像我的博客地址，默认是 <a target="_blank" rel="noopener" href="http://l1cardo.github.io/">http://l1cardo.github.io</a> ，但是你也可以使用 <a target="_blank" rel="noopener" href="https://licardo.cn/">https://licardo.cn</a> 来访问。</p>
<p>首先你要注册一个域名，<code>腾讯云</code> 、<code>阿里云</code> 等国内的域名商也是可以的，而且新用户会有一定的折扣。</p>
<p>注册好域名，接下来就是域名解析了（域名解析就是把你的域名版绑定到 GitHub 提供的域名的意思）。如果你不会填写解析记录，那么我建议你直接按照我的来填写：</p>
<p><img src="https://i.loli.net/2019/09/30/uF8BVDfGC6ZOm4U.png"></p>
<p>在你绑定了新域名之后，原来的<code>你的用户名.github.io</code>并没有失效，只是现在多了一种方式来访问你的博客。</p>
<h3 id="3-配置"><a href="#3-配置" class="headerlink" title="3. 配置"></a>3. 配置</h3><h4 id="3-1-配置-SSH-Key"><a href="#3-1-配置-SSH-Key" class="headerlink" title="3.1 配置 SSH Key"></a>3.1 配置 SSH Key</h4><p>因为你提交代码肯定要拥有你的 GitHub 权限才可以，但是直接使用用户名和密码太不安全了，所以我们使用 SSK key 来解决本地和服务器的连接问题。</p>
<p>打开你的终端，敲入下面的命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> ~/. ssh</span><br></pre></td></tr></table></figure>

<p>这个是检查你是否有 SSH key 的命令，如果提示 <code>No such file or directory</code> 说明你是第一次使用 Git，很好，你符合我们最开始说的本教程的阅读对象</p>
<p>接下来敲入下面的命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C <span class="string">&quot;邮件地址&quot;</span></span><br></pre></td></tr></table></figure>

<p>这里的 <code>邮件地址</code> 最好是你之前注册 GitHub 的地址，这样方便以后的管理。敲入代码后连续按3次回车，最终会生成一个文件在用户目录下，打开用户目录，找到<code>.ssh\id_rsa.pub</code>文件，记事本打开并复制里面的内容。打开你的 GitHub 主页，进入个人设置 -&gt; SSH and GPG keys -&gt; New SSH key，并将刚刚复制的内容填入 Key 那里。Title 你可以随便起。最后别忘了保存。就像下面的图片一样：</p>
<p><img src="https://i.loli.net/2019/09/30/NL61XFjYIDeZTur.png"></p>
<h4 id="3-2-测试-SSH-key是否成功"><a href="#3-2-测试-SSH-key是否成功" class="headerlink" title="3.2. 测试 SSH key是否成功"></a>3.2. 测试 SSH key是否成功</h4><p>在终端里面敲入一下命令行并回车：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh -T git@github.com</span><br></pre></td></tr></table></figure>

<p>如果提示<code>Are you sure you want to continue connecting (yes/no)?</code>，输入<code>yes</code> 并回车，然后会看到：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Hi L1cardo! You<span class="string">&#x27;ve successfully authenticated, but GitHub does not provide shell access.</span></span><br></pre></td></tr></table></figure>

<p>当你看到这个消息，那么恭喜你，SSH key 配置成功啦！</p>
<h4 id="3-3-配置-Git"><a href="#3-3-配置-Git" class="headerlink" title="3.3. 配置 Git"></a>3.3. 配置 Git</h4><p>在终端里面敲入一下命令行并回车：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name <span class="string">&quot;你的 GitHub 用户名&quot;</span></span><br><span class="line">git config --global user.email  <span class="string">&quot;你的 GitHub 注册邮箱&quot;</span></span><br></pre></td></tr></table></figure>

<p>就像我，我的 GitHub 用户名是 <code>L1cardo</code> ，我的 GitHub 注册邮箱是 <code>xxxx@qq.com</code> ，那么我就要这样填写：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name <span class="string">&quot;L1cardo&quot;</span></span><br><span class="line">git config --global user.email <span class="string">&quot;xxxx@qq.com&quot;</span></span><br></pre></td></tr></table></figure>

<h3 id="4-搭建-Hexo-博客"><a href="#4-搭建-Hexo-博客" class="headerlink" title="4. 搭建 Hexo 博客"></a>4. 搭建 Hexo 博客</h3><h4 id="4-1-安装-Hexo"><a href="#4-1-安装-Hexo" class="headerlink" title="4.1. 安装 Hexo"></a>4.1. 安装 Hexo</h4><p>在终端里面敲入一下命令行并回车：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-cli -g</span><br></pre></td></tr></table></figure>

<h4 id="4-2-初始化-Hexo"><a href="#4-2-初始化-Hexo" class="headerlink" title="4.2. 初始化 Hexo"></a>4.2. 初始化 Hexo</h4><p>在电脑的某个地方新建一个存放你博客文件的文件夹（名字可以随便取），比如我的是<code>/Users/licardo/数据/博客</code>，由于这个文件夹将来就作为你存放代码的地方，所以最好不要随便放。</p>
<p>然后在终端里面执行下面的命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /Users/licardo/数据/博客</span><br><span class="line">hexo init</span><br></pre></td></tr></table></figure>

<p>Hexo 会自动下载一些文件到这个目录，目录结构如下图：</p>
<p><img src="https://i.loli.net/2019/09/30/z495wZ7WkKheLyI.png"></p>
<p>然后要让 Hexo 生成博客文件，在终端里面执行：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure>

<p>这样，你的博客就生成了，Hexo 就会在 <code>public</code> 文件夹生成相关 <code>html</code> 文件，这些文件将来都是要提交到 GitHub 去的。</p>
<p><img src="https://i.loli.net/2019/09/30/Q7Ek8Vw6P9YRy1j.png"></p>
<p>接下来我们就可以上传的 GitHub 了，但是我们还什么都没有写，也不知道博客部署完了以后会是什么样子，所以我们最好在本地启动预览服务来看看我们的博客的效果，在终端里执行以下命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo s</span><br></pre></td></tr></table></figure>

<p>打开浏览器访问 <a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000</a> 即可看到内容。默认的主题比较丑，打开时就是这个样子：</p>
<p><img src="https://i.loli.net/2019/09/30/JbwqsmlhtYC8IDd.png"></p>
<h4 id="4-3-修改主题"><a href="#4-3-修改主题" class="headerlink" title="4.3. 修改主题"></a>4.3. 修改主题</h4><p>既然默认主题很丑，那我们别的不做，首先来替换一个好看点的主题。这是 <a target="_blank" rel="noopener" href="https://hexo.io/themes/">官方主题</a> 库，里面有很多好看的、实用的主题。</p>
<p>个人比较喜欢的主题是：<a target="_blank" rel="noopener" href="https://github.com/blinkfox/hexo-theme-matery">hexo-theme-matery</a> ，我的博客也是利用这个主题搭建的，可以看看最终的效果 <a target="_blank" rel="noopener" href="https://licardo.cn/">https://licardo.cn</a></p>
<p>首先下载这个主题，在终端里面执行下面的命令：</p>
<ul>
<li>请在稳定版与最新版中二选一</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /Users/licardo/数据/博客/themes</span><br><span class="line">git <span class="built_in">clone</span> https://github.com/blinkfox/hexo-theme-matery.git            <span class="comment"># 稳定版</span></span><br><span class="line">git <span class="built_in">clone</span> -b develop https://github.com/blinkfox/hexo-theme-matery.git <span class="comment"># 最新版</span></span><br></pre></td></tr></table></figure>

<p>下载的主题你可以在 <code>themes</code> 文件夹里面看到了：</p>
<p><img src="https://i.loli.net/2019/09/30/xVgZr9tAfwYOpsz.png"></p>
<p>然后修改 Hexo 的配置文件，让 Hexo 使用我们下载的主题来生成博客。找到 <code>博客</code> 根目录下的 <code>_config.yml</code> 文件，将其中的 <code>theme: landscape</code>改为<code>theme: hexo-theme-matery</code> ，就像下面一样：</p>
<p><img src="https://i.loli.net/2019/09/30/I2H8QsDLGqdmcbF.png"></p>
<p>然后在终端里面执行下面的命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br><span class="line">hexo g</span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure>

<p>然后打开浏览器访问 <a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000</a> 即可看到更改主题之后的样子了。</p>
<h4 id="4-4-上传到-GitHub"><a href="#4-4-上传到-GitHub" class="headerlink" title="4.4. 上传到 GitHub"></a>4.4. 上传到 GitHub</h4><p>首先要配置好 Hexo 的配置文件，让 Hexo 知道要上传到哪里</p>
<p>修改博客文件夹根目录下的 <code>_config.yml</code> 中有关 deploy 的部分：</p>
<p><img src="https://i.loli.net/2019/09/30/i2rnqUNVxaIkc3t.png"></p>
<p>将上面的 <code>L1cardo</code> 换成你自己的 GitHub 用户名就可以了。</p>
<p>然后安装 Hexo 上传到 GitHub 的插件，终端里面执行：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure>

<p>万事具备了，距离将你的博客部署到 GitHub 上只差一步了，接下来屏住呼吸，在终端里执行下面的命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure>

<p>博客已经上传到 GitHub 了，那么我们距离访问你的博客只剩下最后一步了。</p>
<h4 id="4-5-设置-GitHub-Pages"><a href="#4-5-设置-GitHub-Pages" class="headerlink" title="4.5. 设置 GitHub Pages"></a>4.5. 设置 GitHub Pages</h4><p>GitHub Pages 是 GitHub 为我们提供的静态页面服务，Hexo 就是一个静态博客框架。我们只有开始 GitHub Pages 才能使我们的博客生效并且能够被访问。</p>
<p>打开你的 GitHub 博客仓库进行相关设置，设置步骤如下：</p>
<p><img src="https://i.loli.net/2019/09/30/LYOvyHE1di9W3D4.png"></p>
<p><img src="https://i.loli.net/2019/09/30/YacMl2PynKgjtoA.png"></p>
<p>在这个页面开启 GitHub Pages 服务即可。</p>
<p>其中 ② 是我们自己之前注册过的域名，我们不仅可以通过<code>你的用户名.github.io</code> 来访问，也可以通过自定义域名来访问我们的博客。</p>
<p>其中 ③ 是强制开启 <code>HTTPS</code> 的意思，这样的话 GitHub 会强制时候 <code>HTTPS</code> 来启动你的博客，<code>HTTPS</code> 相比较于 <code>HTTP</code> 来说更安全，所以建议开启。</p>
<p>现在你可以用 <code>你的用户名.github.io</code> 或者用你自己注册的域名来访问你的博客了！</p>
<h4 id="4-6-Hexo-相关命令"><a href="#4-6-Hexo-相关命令" class="headerlink" title="4.6. Hexo 相关命令"></a>4.6. Hexo 相关命令</h4><p>常见命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">hexo new <span class="string">&quot;postName&quot;</span>      <span class="comment"># 新建文章</span></span><br><span class="line">hexo new page <span class="string">&quot;pageName&quot;</span> <span class="comment"># 新建页面</span></span><br><span class="line">hexo generate            <span class="comment"># 生成静态页面至public文件夹</span></span><br><span class="line">hexo server              <span class="comment"># 开启预览访问端口（默认端口4000，&#x27;ctrl + c&#x27;关闭server）</span></span><br><span class="line">hexo deploy              <span class="comment"># 部署到GitHub</span></span><br><span class="line">hexo <span class="built_in">help</span>                <span class="comment"># 查看帮助</span></span><br><span class="line">hexo version             <span class="comment"># 查看Hexo的版本</span></span><br></pre></td></tr></table></figure>

<p>缩写：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">hexo n == hexo new</span><br><span class="line">hexo g == hexo generate</span><br><span class="line">hexo s == hexo server</span><br><span class="line">hexo d == hexo deploy</span><br></pre></td></tr></table></figure>

<p>组合命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo s -g <span class="comment"># 生成并本地预览</span></span><br><span class="line">hexo d -g <span class="comment"># 生成并上传</span></span><br></pre></td></tr></table></figure>

<h4 id="4-7-config-yml-文件"><a href="#4-7-config-yml-文件" class="headerlink" title="4.7. _config.yml 文件"></a>4.7. _config.yml 文件</h4><p>这里面都是一些 Hexo 的全局配置，每个参数的意思都比较简单明了，所以就不作详细介绍了。</p>
<p>需要特别注意的地方是，冒号后面必须有一个空格，否则可能会出问题。</p>
<h3 id="5-写博客"><a href="#5-写博客" class="headerlink" title="5. 写博客"></a>5. 写博客</h3><p>定位到博客根目录地址，在博客根目录下打开终端，然后执行命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new <span class="string">&#x27;my-first-blog&#x27;</span></span><br></pre></td></tr></table></figure>

<p>Hexo 会帮我们在 <code>/source/_posts</code> 文件夹下生成相关 <code>md</code>  格式的文件：</p>
<p><img src="https://i.loli.net/2019/09/30/lNDtLrvfdg2HVa5.png"></p>
<p>我们只需要打开这个文件就可以开始写博客了，默认生成如下内容：</p>
<p><img src="https://i.loli.net/2019/09/30/b9kmR8sDqKcznPE.png"></p>
<p>注意，这里面的默认内容一定不能删除，也就是两个 <code>---</code> 里面的内容不能删除，这个是帮助 Hexo 识别文章的内容，Hexo 能根据里面的内容自动帮你把文章归类，打标签等。两个 <code>---</code> 里面的内容我们称之为 <code>Front-matter</code> ，其实他有很多属性，但是最常用的就是上面的几个了，更详细的属性你可以在 <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/docs/front-matter">这里</a> 进行查看</p>
<p>当然你也可以不用命令来创建新的博客文件，只需在 <code>/source/_posts</code> 文件夹内新建 <code>md</code> 格式的文件进行写博客即可。但是一定要注意，必须要包含 <code>---</code> 内的信息！也就是说必须要有 <code>Front-matter</code> ！</p>
<p>每次写完博客都要使用 Hexo 的相关命令 来生成相关的博客页面，并且部署到 GitHub 上面。</p>
<p>写博客的工具？</p>
<p>因为 Hexo 的博客都是用 <code>md</code> 格式文件来写的，<code>md</code> 格式是 Markdown 文件的格式，所以只要使用规范的 Markdown 语法进行书写即可。</p>
<p>当然也是有好的 Markdown 编辑器的，在这里我推荐 <a target="_blank" rel="noopener" href="https://github.com/marktext/marktext">Mark Text</a> ，一个跨平台的 Markdown 编辑器，开源免费，而且实时渲染的特性使得即使不会 Markdown 语法也能进行优美的 Markdown 写作。我的所有的 Markdown 文件都是用它来书写的。</p>
<h3 id="6-最终效果"><a href="#6-最终效果" class="headerlink" title="6. 最终效果"></a>6. 最终效果</h3><p>可以访问我的博客来查看效果：<a target="_blank" rel="noopener" href="https://licardo.cn/">https://licardo.cn</a></p>
<p>当然你也可以使用其他主题，动手能力强的话，你也可以自己修改一些主题的内容，去创建属于你自己的博客！</p>
<h3 id="7-参考"><a href="#7-参考" class="headerlink" title="7. 参考"></a>7. 参考</h3><p><a target="_blank" rel="noopener" href="http://blog.haoji.me/build-blog-website-by-hexo-github.html">http://blog.haoji.me/build-blog-website-by-hexo-github.html</a></p>
<div style="display: flex;align-items: center;justify-content: space-evenly;padding-top: 40px;">
  <img src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/notbyai_cn.png" alt="真人撰写" style="height: 42px;">
  <img src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/notbyai_en.png" alt="written by human" style="height: 42px;">
</div>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://blog.licardo.cn">Licardo</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://blog.licardo.cn/posts/57ddc7cc/">https://blog.licardo.cn/posts/57ddc7cc/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.licardo.cn" target="_blank">Licardo</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Hexo/">Hexo</a></div><div class="post_share"><div class="social-share" data-image="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/blogging_vpvv.svg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.staticfile.org/butterfly-extsrc/1.1.3/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.staticfile.org/butterfly-extsrc/1.1.3/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i>赞助</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/donate/wechat.jpg" target="_blank"><img class="post-qr-code-img" src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/donate/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/donate/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/donate/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/f1670866/" title="Matery 主题详细配置教程"><img class="cover" src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/content_vbqo.svg" onerror="onerror=null;src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Matery 主题详细配置教程</div></div></a></div><div class="next-post pull-right"><a href="/posts/aabce9f4/" title="出国交流总结"><img class="cover" src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/adventure_4hum.svg" onerror="onerror=null;src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">出国交流总结</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/105bb8da/" title="Matery 主题安装豆瓣插件"><img class="cover" src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/wordpress_utxt.svg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-10-29</div><div class="title">Matery 主题安装豆瓣插件</div></div></a></div><div><a href="/posts/e53fd116/" title="Matery 主题字体替换"><img class="cover" src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/fashion_blogging_w9ol.svg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-10-04</div><div class="title">Matery 主题字体替换</div></div></a></div><div><a href="/posts/f1670866/" title="Matery 主题详细配置教程"><img class="cover" src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/content_vbqo.svg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-10-04</div><div class="title">Matery 主题详细配置教程</div></div></a></div></div></div><hr class="custom-hr"/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/avatar.png" onerror="this.onerror=null;this.src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="avatar"/></div><div class="author-info__name">Licardo</div><div class="author-info__description">喜欢编程的医学生</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">27</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">12</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/L1cardo"><i class="fab fa-github"></i><span>关注我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/L1cardo" target="_blank" title="GitHub"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:albert.abdilim@foxmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://twitter.com/AlbertAbdilim" target="_blank" title="Twitter"><i class="fab fa-twitter"></i></a><a class="social-icon" href="https://weibo.com/1935602951" target="_blank" title="Weibo"><i class="fab fa-weibo"></i></a><a class="social-icon" href="https://space.bilibili.com/7403418" target="_blank" title="Bilibili"><i class="fab fa-bilibili"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">欢迎来到我的博客, 喜欢请收藏!</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Hexo-%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B"><span class="toc-number">1.</span> <span class="toc-text">Hexo 搭建个人博客详细教程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-Hexo-%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.0.1.</span> <span class="toc-text">1. Hexo 介绍</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-1-%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="toc-number">1.0.1.1.</span> <span class="toc-text">1.1 准备工作</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E8%AE%BE%E7%BD%AE-GitHub-%E5%8D%9A%E5%AE%A2"><span class="toc-number">1.0.2.</span> <span class="toc-text">2. 设置 GitHub 博客</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-1-%E5%88%9B%E5%BB%BA-GitHub-%E4%BB%93%E5%BA%93"><span class="toc-number">1.0.2.1.</span> <span class="toc-text">2.1. 创建 GitHub 仓库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-%E7%BB%91%E5%AE%9A%E5%9F%9F%E5%90%8D%EF%BC%88%E5%8F%AF%E9%80%89%EF%BC%89"><span class="toc-number">1.0.2.2.</span> <span class="toc-text">2.2. 绑定域名（可选）</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E9%85%8D%E7%BD%AE"><span class="toc-number">1.0.3.</span> <span class="toc-text">3. 配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-1-%E9%85%8D%E7%BD%AE-SSH-Key"><span class="toc-number">1.0.3.1.</span> <span class="toc-text">3.1 配置 SSH Key</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-%E6%B5%8B%E8%AF%95-SSH-key%E6%98%AF%E5%90%A6%E6%88%90%E5%8A%9F"><span class="toc-number">1.0.3.2.</span> <span class="toc-text">3.2. 测试 SSH key是否成功</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-3-%E9%85%8D%E7%BD%AE-Git"><span class="toc-number">1.0.3.3.</span> <span class="toc-text">3.3. 配置 Git</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-%E6%90%AD%E5%BB%BA-Hexo-%E5%8D%9A%E5%AE%A2"><span class="toc-number">1.0.4.</span> <span class="toc-text">4. 搭建 Hexo 博客</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#4-1-%E5%AE%89%E8%A3%85-Hexo"><span class="toc-number">1.0.4.1.</span> <span class="toc-text">4.1. 安装 Hexo</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-2-%E5%88%9D%E5%A7%8B%E5%8C%96-Hexo"><span class="toc-number">1.0.4.2.</span> <span class="toc-text">4.2. 初始化 Hexo</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-3-%E4%BF%AE%E6%94%B9%E4%B8%BB%E9%A2%98"><span class="toc-number">1.0.4.3.</span> <span class="toc-text">4.3. 修改主题</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-4-%E4%B8%8A%E4%BC%A0%E5%88%B0-GitHub"><span class="toc-number">1.0.4.4.</span> <span class="toc-text">4.4. 上传到 GitHub</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-5-%E8%AE%BE%E7%BD%AE-GitHub-Pages"><span class="toc-number">1.0.4.5.</span> <span class="toc-text">4.5. 设置 GitHub Pages</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-6-Hexo-%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4"><span class="toc-number">1.0.4.6.</span> <span class="toc-text">4.6. Hexo 相关命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-7-config-yml-%E6%96%87%E4%BB%B6"><span class="toc-number">1.0.4.7.</span> <span class="toc-text">4.7. _config.yml 文件</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-%E5%86%99%E5%8D%9A%E5%AE%A2"><span class="toc-number">1.0.5.</span> <span class="toc-text">5. 写博客</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-%E6%9C%80%E7%BB%88%E6%95%88%E6%9E%9C"><span class="toc-number">1.0.6.</span> <span class="toc-text">6. 最终效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-%E5%8F%82%E8%80%83"><span class="toc-number">1.0.7.</span> <span class="toc-text">7. 参考</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/2a02866e/" title="FIT 文件对比工具"><img src="https://staticcn.coros.com/coros-web-faq/public/img/banner.ff751ead.png" onerror="this.onerror=null;this.src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="FIT 文件对比工具"/></a><div class="content"><a class="title" href="/posts/2a02866e/" title="FIT 文件对比工具">FIT 文件对比工具</a><time datetime="2024-07-14T00:00:00.000Z" title="发表于 2024-07-14 00:00:00">2024-07-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5a01448b/" title="板载 ELRS 密码设置"><img src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/ExpressLRS/ExpressLRS-Hardware/master/img/banner.png" onerror="this.onerror=null;this.src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="板载 ELRS 密码设置"/></a><div class="content"><a class="title" href="/posts/5a01448b/" title="板载 ELRS 密码设置">板载 ELRS 密码设置</a><time datetime="2022-06-03T00:00:00.000Z" title="发表于 2022-06-03 00:00:00">2022-06-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/31bc9bc5/" title="Apple Device Model Name"><img src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/web_devices_ad58.svg" onerror="this.onerror=null;this.src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="Apple Device Model Name"/></a><div class="content"><a class="title" href="/posts/31bc9bc5/" title="Apple Device Model Name">Apple Device Model Name</a><time datetime="2020-11-17T00:00:00.000Z" title="发表于 2020-11-17 00:00:00">2020-11-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/209ca420/" title="App Store 多账号自动登录器"><img src="https://42f2671d685f51e10fc6-b9fcecea3e50b3b59bdc28dead054ebc.ssl.cf5.rackcdn.com/illustrations/performance_overview_p9bm.svg" onerror="this.onerror=null;this.src='https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/Image-Hosting/master/blog/loading.gif'" alt="App Store 多账号自动登录器"/></a><div class="content"><a class="title" href="/posts/209ca420/" title="App Store 多账号自动登录器">App Store 多账号自动登录器</a><time datetime="2020-10-04T00:00:00.000Z" title="发表于 2020-10-04 00:00:00">2020-10-04</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/8ba628ad/" title="隐私政策">隐私政策</a><time datetime="2020-06-20T00:00:00.000Z" title="发表于 2020-06-20 00:00:00">2020-06-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2024 By Licardo</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a target="_blank" rel="noopener" href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral"><img class="icp-icon" src="https://mirror.ghproxy.com/https://raw.githubusercontent.com/L1cardo/l1cardo.github.io/blog/themes/butterfly/source/img/upyun.png" style="max-height:1.2em"><span></span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="https://cdn.staticfile.org/hexo-theme-butterfly/4.13.0/js/utils.min.js"></script><script src="https://cdn.staticfile.org/hexo-theme-butterfly/4.13.0/js/main.min.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/5.0.33/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"><script>(() => {
  const getCount = () => {
    const countELement = document.getElementById('twikoo-count')
    if(!countELement) return
    twikoo.getCommentsCount({
      envId: 'blog-comment-2ggu4dqb436a1407',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(res => {
      countELement.textContent = res[0].count
    }).catch(err => {
      console.error(err)
    })
  }

  const init = () => {
    twikoo.init(Object.assign({
      el: '#twikoo-wrap',
      envId: 'blog-comment-2ggu4dqb436a1407',
      region: '',
      onCommentLoaded: () => {
        btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
      }
    }, null))

    GLOBAL_CONFIG_SITE.isPost && getCount()
  }

  const loadTwikoo = () => {
    if (typeof twikoo === 'object') setTimeout(init,0)
    else getScript('https://cdn.staticfile.org/twikoo/1.6.31/twikoo.all.min.js').then(init)
  }

  if ('Twikoo' === 'Twikoo' || !false) {
    if (false) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo()
  } else {
    window.loadOtherComment = loadTwikoo
  }
})()</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="https://cdn.staticfile.org/hexo-theme-butterfly/4.13.0/js/search/local-search.min.js"></script></div></div></body></html>